/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package HomeWork7Threads;

import java.awt.*;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Jakim
 */
public class SpinThread extends Thread{

    private Choice choiceStep;
    private int spinStep;
    private TextField txtSpin;

    public SpinThread(TextField txtSpin, Choice choiceStep){
        this.choiceStep = choiceStep;
        this.txtSpin = txtSpin;
    }

    @Override
    public void run() {
        try {
            int counter = 0;
            while(!Thread.interrupted()){
                this.spinStep = Integer.parseInt(this.choiceStep.getSelectedItem());
                this.txtSpin.setText(String.valueOf(counter));
                counter += this.spinStep;
                Thread.sleep(1000);
            }
        } catch (InterruptedException ex) {
                Logger.getLogger(SpinThread.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
